package org.gdstash.ui;

import org.gdstash.ui.util.AdjustableTabbedPane;
import org.gdstash.util.GDImagePool;
import org.gdstash.util.GDMsgFormatter;

import javax.swing.*;
import java.awt.*;

public class GDCollectionTabbedPane extends AdjustableTabbedPane {
    private GDStashFrame frame;
    private GDCollectionPane pnlItemCollection;
    private GDCollectionSetPane pnlSetCollection;

    public GDCollectionTabbedPane(final GDStashFrame frame) {
        this.frame = frame;
        this.pnlItemCollection = new GDCollectionPane(frame);
        this.pnlSetCollection = new GDCollectionSetPane(frame);
        this.add(this.pnlItemCollection);
        this.add(this.pnlSetCollection);
        this.adjustUI();
    }

    @Override
    public void adjustUI() {
        final Font fntLabel = UIManager.getDefaults().getFont("Label.font");
        Font fntTabbed = UIManager.getDefaults().getFont("TabbedPane.font");
        fntTabbed = fntTabbed.deriveFont((float) GDStashFrame.iniConfig.sectUI.fontSize);
        this.setFont(fntTabbed);
        int index = 0;
        this.setTitleAt(index, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "HEADER_ITEM_COLL"));
        this.setIconAt(index, GDImagePool.iconTabCollection16);
        ++index;
        this.setTitleAt(index, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "HEADER_SET_COLL"));
        this.setIconAt(index, GDImagePool.iconTabCollectionSet16);
        ++index;
        this.pnlItemCollection.adjustUI();
        this.pnlSetCollection.adjustUI();
    }

    public void updateConfig() {
        if (this.pnlItemCollection != null) {
            this.pnlItemCollection.updateConfig();
        }
    }
}
